<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>修改用户信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/xadmin.css">
    <script type="text/javascript" src="../assets/js/jquery-1.8.3.min.js"></script>
    <script src="../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/xadmin.js"></script>

<body>
<div class="layui-fluid">
    <div class="layui-row">
        <div class="layui-form" style="margin-left: 30%;margin-top: 10%">
            <div class="layui-form-item">
                <label  class="layui-form-label">
                    <span class="x-red">*</span>ID</label>
                <div class="layui-input-inline">
                    <input type="text" id="uid" readonly="readonly" autocomplete="off" class="layui-input"></div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red"></span></div></div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>姓名</label>
                <div class="layui-input-inline">
                    <input type="text" id="uname" maxlength="5" autocomplete="off" class="layui-input"></div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red"></span></div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>手机</label>
                <div class="layui-input-inline">
                    <input type="text" id="uphone" maxlength="11" name="username" required="" lay-verify="nikename" autocomplete="off" class="layui-input"></div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>性别</label>
                <div class="layui-input-inline">
                    <input type="text" id="usex" maxlength="1" name="username" required="" lay-verify="nikename" autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label  class="layui-form-label">
                    <span class="x-red">*</span>年龄</label>
                <div class="layui-input-inline">
                    <input type="text" id="uage" maxlength="3" name="username" required="" lay-verify="nikename" autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <button class="layui-btn" lay-filter="add" id="butt">修改</button></div>
        </div>
    </div>
</div>

</body>

</html>
<script>
    layui.use(['table', 'jquery'], function () {
        var table = layui.table;
        var $ = layui.jquery;
        $("#uid").click(function (){
            layer.msg('业主id不能修改!',{
                icon:1
                ,time:1000
            });
        })

        $.ajax({
            type: 'POST',
            url: "http://localhost:8080/api/zhfind",
            data: {"id": sessionStorage.getItem("uid")},
            headers: {
                token: localStorage.getItem("token")
            },
            datatype: "json",
            success: function (data) {
                let uid = sessionStorage.getItem("uid")
                let uname = sessionStorage.getItem("uname")
                let uphone = sessionStorage.getItem("uphone")
                let usex = sessionStorage.getItem("usex")
                let uage = sessionStorage.getItem("uage")
                $("#uid").val(uid);
                $("#uname").val(uname);
                $("#uphone").val(uphone);
                $("#usex").val(usex);
                $("#uage").val(uage);

            }
        })
    })
    $("#butt").click(function () {
        layui.use(['table', 'jquery'], function () {
            var table = layui.table;
            var $ = layui.jquery;
            let uid=  $("#uid").val();
            let uname=$("#uname").val();
            let uphone=$("#uphone").val();
            let usex=$("#usex").val();
            let uage=$("#uage").val();
            $.ajax({
                type: "POST",
                url: "http://localhost:8080/api/userupdate",
                data: {
                    "uId": uid,
                    "uName": uname,
                    "uPhone": uphone,
                    "uSex": usex,
                    "uAge": uage,
                },
                headers: {
                    token: localStorage.getItem("token")
                },
                datatype: "json",
                success: function (data) {
                    if (data) {
                        var index = parent.layer.getFrameIndex(window.name);
                        layer.msg('用户信息修改成功!',{
                            icon:1
                            ,time:1000
                        },function (){
                            parent.layer.close(index);//关闭当前页
                        });
                    }
                }
            })
        })
    })


</script>